#!/bin/bash

olv line Phone $@

if [ "$1 $2" == "end call" ]; then
    adb shell input keyevent KEYCODE_ENDCALL
else
    #wake phone
    text=$(printf '%s%%s' ${@})  # concatenate and replace spaces with %s
    text=${text%%%s}  # remove the trailing %s
    text=${text//\'/\\\'}  # escape single quotes
    text=${text//\"/\\\"}  # escape double quotes
    # echo "[$text]"  # debugging

    adb shell input text "$text"
    adb shell input keyevent 66
fi

